Ext.define("SHApp.EmployeeInfo.Identification.Form", {
    extend: "BLBTSystem.Form",
    submitUrl: "api/identification?format=json",
    winWidth: 560,
    winHeight: 200,
    txtStartDtID: "_txtStartDtID",
    txtEndDtID: "_txtEndDtID",
    txtProidID: "_txtProidID",
    initComponent: function () {
        var me = this;
        Ext.apply(this);
        this.txtStartDtID += me.id;
        this.txtEndDtID += me.id;
        this.txtProidID += me.id;
        this.createItems();
        this.callParent(arguments);
    },
    createItems: function () {
        var me = this;
        me.items = [{
            width: 260,
            border: false,
            bodyStyle: "background:#DFE9F6",
            layout: { type: "vbox", align: "stretch" },
            items: [
				{
				    xtype: "textfield",
				    fieldLabel: "ID",
				    name: "Id",
				    hidden: true
				}, Ext.create("BLBTSystem.CmbYesNo", {
				    fieldLabel: "<span style='color:red'>*</span>证件类型:",
				    fields: ["text"],
				    data: [["身份证"], ["护照"], ["学生证"], ["军官证"], ["驾照"]],
				    valueField: "text",
				    displayField: "text",
				    name: "IdentType",
				    maxLength: 50,
				    allowBlank: false,
				    blankText: "请选择证件类型！"
				}), {
				    fieldLabel: "<span style='color:red'>*</span>证件编号",
				    xtype: "textfield",
				    name: "IdentNumber",
				    maxLength: 30,
				    allowBlank: false,
				    blankText: "请输入证件编号!"
				}, {
				    fieldLabel: "<span style='color:red'>*</span>发证单位",
				    xtype: "textfield",
				    name: "IdentAuthority",
				    maxLength: 50,
				    allowBlank: false,
				    blankText: "请输入发证单位!"
				}]
        }, {
            width: 260,
            border: false,
            bodyStyle: "background:#DFE9F6",
            layout: { type: "vbox", align: "stretch" },
            items: [{
                xtype: "datefield",
                fieldLabel: "<span style='color:red'>*</span>起始日期",
                value: new Date(),
                // maxValue: new Date(),
                name: "StartDate",
                format: 'Y-m-d',
                allowBlank: false,
                blankText: "请输入起始日期!",
                id: me.txtStartDtID,
                listeners: {
                    change: function (dt, newValue, oldValue, eOpts) {
                        var startDt = newValue.getFullYear(),
                            endDt = me.down("#" + me.txtEndDtID).getValue().getFullYear(),
                            priod = endDt - startDt + "年";
                        me.down("#" + me.txtProidID).setValue(priod);
                    }
                }
            }, {
                xtype: "datefield",
                fieldLabel: "<span style='color:red'>*</span>截止日期",
                value: new Date(),
                name: "EndDate",
                format: 'Y-m-d',
                allowBlank: false,
                blankText: "请输入截止日期!",
                id: me.txtEndDtID,
                listeners: {
                    change: function (dt, newValue, oldValue, eOpts) {
                        var startDt = me.down("#" + me.txtStartDtID).getValue().getFullYear(),
                            endDt = newValue.getFullYear(),
                            priod = endDt - startDt + "年";
                        me.down("#" + me.txtProidID).setValue(priod);
                    }
                }
            }, {
                fieldLabel: "有效期",
                xtype: "textfield",
                name: "Period",
                maxLength: 50,
                id: me.txtProidID,
                readOnly: true
            }, {
                xtype: "hiddenfield",
                name: "EmpId",
                fieldLabel: "员工Id"

            }, {
                xtype: "hiddenfield",
                name: "EmpName",
                fieldLabel: "员工姓名"
            }]
        }
		];
    }

});